package io.github.lianghengyuan.influxdb.config;

import okhttp3.ConnectionPool;
import okhttp3.OkHttpClient;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

@Configuration
public class InfluxDbOkHttpClientBuilderProvider implements org.springframework.boot.autoconfigure.influx.InfluxDbOkHttpClientBuilderProvider {
    /**
     * Gets a result.
     *
     * @return a result
     */
    @Override
    public OkHttpClient.Builder get() {
        // 设置超时时间为100秒
        OkHttpClient.Builder builder = new OkHttpClient.Builder()
                .connectTimeout(1000, TimeUnit.SECONDS)
                .readTimeout(1000, TimeUnit.SECONDS)
                .writeTimeout(1000, TimeUnit.SECONDS);
        builder.setConnectionPool$okhttp(new ConnectionPool(50,60,TimeUnit.SECONDS));
        return builder;
    }
}
